//
//  ViewController.m
//  CirculateRequestData
//
//  Created by 曾墨 on 16/8/26.
//  Copyright © 2016年 YuanJiang. All rights reserved.
//

#import "ViewController.h"
#import "AFNetworking.h"
@interface ViewController ()

@end


@implementation ViewController
//http://blog.csdn.net/heberan/article/details/51549543
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
   //数据请求
    NSString *urlStr;
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.requestSerializer.timeoutInterval =10.0;
     // 声明上传的是json格式的参数，需要你和后台约定好，不然会出现后台无法获取到你上传的参数问题
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];//manager
    // 声明获取到的数据格式
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithArray:@[@"text/html",@"text/plain"]];
    // AFN不会解析,数据是data，需要自己解析
    //    manager.responseSerializer = [AFJSONResponseSerializer serializer]; // AFN会JSON解析返回的数据
    // 个人建议还是自己解析的比较好，有时接口返回的数据不合格会报3840错误，大致是AFN无法解析返回来的数据
    
    for (int i=0;i<2000; i++) {
        urlStr = [NSString stringWithFormat:@"http://m.minbingtuan.cn:8000/systemadmin.php/api/notice/Seach?managerId=%d",i];
        
       [manager GET:urlStr parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
           ;
       } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
           NSLog(@"%@",responseObject);
           NSLog(@"当前请求的id是 %d",i);
       } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
           ;
       }];
        
        
    }
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
